using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using System.Windows.Forms;
using ICP_MS.Plugin.Experiment.Properties;
using ZedGraph;

namespace ICP_MS.Plugin.Experiment;

public class FormSpectrums : Form
{
	private ExperimentDatas experiment = null;

	private ExperimentDB db = null;

	private double PeakThreshold = 1000.0;

	public Hashtable StoreNodeState = new Hashtable();

	public Hashtable StoreNodeColor = new Hashtable();

	private IContainer components = null;

	private ToolStrip toolStrip2;

	private TreeView treeSpectrum;

	private ToolStripLabel toolStripLabel1;

	private ToolStripTextBox txtThreshold;

	private ToolStripButton tsbtnShowLabel;

	private LabelGraph spectraGraph;

	private SplitContainer splitContainer1;

	private TableLayoutPanel tableLayoutPanel1;

	private ToolStripButton tsbtnSaveExcel;

	private ToolStripButton toolStripButtonRefresh;

	public FormSpectrums()
	{
		InitializeComponent();
	}

	public void SetParams(ExperimentDatas experiment, ExperimentDB db)
	{
		this.experiment = experiment;
		this.db = db;
		experiment.refreshChanged += Experiment_refreshChanged;
	}

	private void Experiment_refreshChanged(object sender, EventArgs e)
	{
		Dictionary<string, Color> Dictag = new Dictionary<string, Color>();
		List<string> tagList = new List<string>();
		foreach (CurveItem curve in spectraGraph.GraphPane.CurveList)
		{
			if (!tagList.Contains(curve.Tag.ToString()))
			{
				tagList.Add(curve.Tag.ToString());
				Dictag.Add(curve.Tag.ToString(), curve.Color);
			}
		}
		spectraGraph.GraphPane.CurveList.Clear();
		spectraGraph.RemoveAllLabels();
		foreach (string tag in tagList)
		{
			if (tag != "")
			{
				string[] strtag = tag.Split(',');
				if (strtag.Count() < 3)
				{
					break;
				}
				int guid = Convert.ToInt32(strtag[0]);
				int mode = Convert.ToInt32(strtag[1]);
				int runindex = Convert.ToInt32(strtag[2]);
				IEnumerable<SpectrumInfos> currentspectrum = experiment.Spectrums.Where((SpectrumInfos spectrum) => spectrum.sampleId == guid && spectrum.scanType == mode && spectrum.scanIndex == runindex && spectrum.isTest);
				if (currentspectrum != null && currentspectrum.Count() > 0)
				{
					DrawSpectrum(currentspectrum.First(), currentspectrum.First().label, Dictag[tag], tag, bCheck: true);
				}
			}
		}
	}

	public void UpdateSelectedIsotopes(object sender, EventArgs e)
	{
	}

	public void UpdateInternalStandards(object sender, EventArgs e)
	{
	}

	public void UpdateSamples(object sender, EventArgs e)
	{
		SetupSpectrumTree();
	}

	public void AddLabel()
	{
	}

	private void SetupSpectrumTree()
	{
		Color[] colors = new Color[6]
		{
			Color.Blue,
			Color.Red,
			Color.Green,
			Color.Gold,
			Color.Black,
			Color.Purple
		};
		int index = -1;
		treeSpectrum.Nodes.Clear();
		foreach (SamplesInfos sample in experiment.Samples)
		{
			index++;
			if (index == 6)
			{
				index = 0;
			}
			TreeNode node = new TreeNode(sample.label);
			node.Tag = sample.guid;
			TreeNode node2 = new TreeNode(Lang.Txt("AddFormSpectrums.FullScan"));
			node2.Tag = "0";
			TreeNode node3 = new TreeNode(Lang.Txt("AddFormSpectrums.PeakScan"));
			node3.Tag = "1";
			if (experiment.Scan.isSurvey)
			{
				int j;
				for (j = 0; j < sample.surveys; j++)
				{
					TreeNode leaf2 = new TreeNode(Lang.Txt("AddFormSpectrums.The") + (j + 1) + Lang.Txt("AddFormSpectrums.Time"));
					leaf2.Tag = j;
					IEnumerable<SpectrumInfos> spectrums2 = experiment.Spectrums.Where((SpectrumInfos spectrum) => spectrum.sampleId == sample.guid && spectrum.scanType == 0 && spectrum.scanIndex == j && spectrum.isTest);
					if (spectrums2 != null && spectrums2.Count() > 0)
					{
						leaf2.ForeColor = colors[index];
					}
					else
					{
						leaf2.ForeColor = Color.Gray;
					}
					node2.Nodes.Add(leaf2);
				}
			}
			int i;
			for (i = 0; i < sample.mains; i++)
			{
				TreeNode leaf = new TreeNode(Lang.Txt("AddFormSpectrums.The") + (i + 1) + Lang.Txt("AddFormSpectrums.Time"));
				leaf.Tag = i;
				IEnumerable<SpectrumInfos> spectrums = experiment.Spectrums.Where((SpectrumInfos spectrum) => spectrum.sampleId == sample.guid && (spectrum.scanType == 1 || spectrum.scanType == 2) && spectrum.scanIndex == i && spectrum.isTest);
				if (spectrums != null && spectrums.Count() > 0)
				{
					leaf.ForeColor = colors[index];
				}
				else
				{
					leaf.ForeColor = Color.Gray;
				}
				node3.Nodes.Add(leaf);
			}
			node.Nodes.Add(node2);
			node.Nodes.Add(node3);
			node.ExpandAll();
			treeSpectrum.Nodes.Add(node);
		}
	}

	private void treeSpectrum_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
	{
	}

	private void FormSpectrums_Load(object sender, EventArgs e)
	{
		base.WindowState = FormWindowState.Maximized;
		SetupSpectrumTree();
		spectraGraph.GraphPane.Title.Text = "";
		spectraGraph.GraphPane.XAxis.Title.Text = "质量数";
		spectraGraph.GraphPane.YAxis.Title.Text = "强度";
		tsbtnShowLabel.Checked = spectraGraph.IsShowLabel;
		ApplyResources();
	}

	private void ApplyResources()
	{
		tsbtnShowLabel.Text = Lang.Txt("FormSpectrum.LabelElement.Text");
		toolStripLabel1.Text = Lang.Txt("FormSpectrum.PeakThreshold.Text");
		spectraGraph.GraphPane.XAxis.Title.Text = Lang.Txt("AddFormSpectrums.Mass");
		spectraGraph.GraphPane.YAxis.Title.Text = Lang.Txt("AddFormSpectrums.Intensity");
		toolStripButtonRefresh.Text = Lang.Txt("AddFormSpectrums.Refresh");
		tsbtnSaveExcel.Text = Lang.Txt("AddFormSpectrums.Save");
	}

	private void treeSpectrum_BeforeExpand(object sender, TreeViewCancelEventArgs e)
	{
	}

	private void DrawLabel(SpectrumInfos spectrum, string tag, Color color)
	{
		GraphPane pane = spectraGraph.GraphPane;
		List<AnalyteIsotope> isotopes = (List<AnalyteIsotope>)db.GetAnalyteIsotopesMax();
		foreach (AnalyteIsotope isotope in isotopes)
		{
			GetLabelResult(isotope, spectrum, tag, color);
		}
		spectraGraph.AxisChange();
		spectraGraph.Refresh();
	}

	private void GetLabelResult(AnalyteIsotope isotope, SpectrumInfos spectrum, string tag, Color color)
	{
		double mass = isotope.mass;
		string symbol = isotope.symbol;
		double max = 0.0;
		double massMax = 0.0;
		int idx = 0;
		for (int i = 0; i < spectrum.mass.Length; i++)
		{
			if (Math.Abs(spectrum.mass[i] - mass) < 0.2 && spectrum.intensity[i] > max)
			{
				max = spectrum.intensity[i];
				massMax = spectrum.mass[i];
				idx = i;
			}
		}
		if (max > PeakThreshold)
		{
			spectraGraph.AddMassLabel($" symbol:{symbol}", mass, max, massMax, tag, color);
		}
	}

	public double FindCentroid(int idx, double height, out double width, double[] Mass, double[] Intensity)
	{
		double center = 0.0;
		int ileft = idx - 1;
		int iright = idx;
		while (ileft > 0 && Intensity[ileft] > height)
		{
			ileft--;
		}
		for (; iright < Intensity.Length - 1 && Intensity[iright] > height; iright++)
		{
		}
		double xleft = InterpolateMass(Mass[ileft], Intensity[ileft], Mass[ileft + 1], Intensity[ileft + 1], height);
		double xright = InterpolateMass(Mass[iright - 1], Intensity[iright - 1], Mass[iright], Intensity[iright], height);
		center = (xleft + xright) / 2.0;
		width = Math.Abs(xleft - xright);
		return center;
	}

	private static double InterpolateMass(double x1, double y1, double x2, double y2, double y)
	{
		if (x1 == x2)
		{
			return x1;
		}
		double a = (y2 - y1) / (x2 - x1);
		double b = y1 - a * x1;
		return (y - b) / a;
	}

	private void DrawSpectrum(SpectrumInfos spectrum, string label, Color color, string tag, bool bCheck)
	{
		GraphPane pane = spectraGraph.GraphPane;
		List<int> indexList = new List<int>();
		pane.Title.Text = label + "(" + Lang.Txt("AddFormSpectrums.The") + (spectrum.scanIndex + 1) + Lang.Txt("AddFormSpectrums.Time") + ")";
		bool bExisted = false;
		for (int j = 0; j < pane.CurveList.Count; j++)
		{
			if (pane.CurveList[j].Tag.ToString() == tag)
			{
				bExisted = true;
				LineItem line = pane.CurveList[j] as LineItem;
				if (bCheck)
				{
					line.Line.Width = 2f;
				}
				else
				{
					indexList.Add(j);
				}
			}
		}
		if (!bCheck)
		{
			if (indexList.Count > 0)
			{
				pane.CurveList.RemoveRange(indexList[0], indexList.Count);
				spectraGraph.RemoveLabel(tag);
				pane.AxisChange();
				spectraGraph.Refresh();
			}
		}
		else
		{
			if (bExisted)
			{
				return;
			}
			LineItem line2 = null;
			double last = -1.0;
			for (int i = 0; i < spectrum.mass.Length; i++)
			{
				if (spectrum.mass[i] - last > 0.9)
				{
					line2 = pane.AddCurve("", new PointPairList(), color, SymbolType.Circle);
					line2.Symbol.Fill = new Fill(line2.Color);
					line2.Symbol.Size = 2f;
					line2.Tag = tag;
				}
				last = spectrum.mass[i];
				line2.AddPoint(spectrum.mass[i], spectrum.intensity[i]);
			}
			pane.AxisChange();
			spectraGraph.Refresh();
			if (spectraGraph.IsShowLabel)
			{
				DrawLabel(spectrum, tag, color);
			}
		}
	}

	private void tsbtnShowLabel_Click(object sender, EventArgs e)
	{
		tsbtnShowLabel.Checked = !tsbtnShowLabel.Checked;
		spectraGraph.IsShowLabel = tsbtnShowLabel.Checked;
		spectraGraph.AxisChange();
		spectraGraph.Refresh();
	}

	private void txtThreshold_TextChanged(object sender, EventArgs e)
	{
		try
		{
			PeakThreshold = double.Parse(txtThreshold.Text);
		}
		catch (Exception)
		{
		}
	}

	private void toolStripButton8_Click(object sender, EventArgs e)
	{
		spectraGraph.RestoreScale(spectraGraph.GraphPane);
	}

	private void tsbtnSaveExcel_Click(object sender, EventArgs e)
	{
		try
		{
			if (spectraGraph.GraphPane.CurveList.Count() > 0)
			{
				SaveFileDialog saveFileDialog = new SaveFileDialog();
				saveFileDialog.Title = Lang.Txt("AddFormSpectrums.SaveMessage");
				saveFileDialog.Filter = "CSV文件|*.csv";
				saveFileDialog.DefaultExt = "*.csv";
				if (saveFileDialog.ShowDialog() != DialogResult.OK)
				{
					return;
				}
				StreamWriter stream = null;
				string rowStr = string.Empty;
				if (!File.Exists(saveFileDialog.FileName))
				{
					File.Create(saveFileDialog.FileName);
				}
				stream = new StreamWriter(saveFileDialog.FileName);
				rowStr = Lang.Txt("AddFormSpectrums.Mass") + "," + Lang.Txt("AddFormSpectrums.Intensity") + "\n";
				for (int j = 0; j < spectraGraph.GraphPane.CurveList.Count; j++)
				{
					CurveItem curve = spectraGraph.GraphPane.CurveList[j];
					for (int i = 0; i < curve.Points.Count; i++)
					{
						rowStr = rowStr + curve.Points[i].X + "," + curve.Points[i].Y + "\n";
					}
				}
				stream.Write(rowStr);
				stream.Close();
			}
			else
			{
				MessageBox.Show(Lang.Txt("AddFormSpectrums.SelectSpectrum"), Lang.Txt("AddFormSpectrums.Warn"), MessageBoxButtons.OK);
			}
		}
		catch (Exception ex)
		{
			MessageBox.Show(ex.Message, Lang.Txt("AddFormSpectrums.Warn"), MessageBoxButtons.OK);
		}
	}

	public void AddNodeStateToHashTable(string fullPath, bool? isExpend)
	{
		if (!StoreNodeState.ContainsKey(fullPath))
		{
			StoreNodeState.Add(fullPath, isExpend);
		}
	}

	public void ClearStoreNodeState()
	{
		StoreNodeState.Clear();
		StoreNodeColor.Clear();
	}

	public bool? FindNodeStateByFullPath(string fullPath)
	{
		if (StoreNodeState.ContainsKey(fullPath))
		{
			return (bool?)StoreNodeState[fullPath];
		}
		return false;
	}

	public Color FindNodeColorByFullPath(string fullPath)
	{
		if (StoreNodeColor.ContainsKey(fullPath))
		{
			return (Color)StoreNodeColor[fullPath];
		}
		return Color.White;
	}

	public void ExecStoreNodeState(TreeNode treeNode)
	{
		if (treeNode.Nodes == null || treeNode.Nodes.Count == 0)
		{
			return;
		}
		foreach (TreeNode node in treeNode.Nodes)
		{
			if (node.Checked)
			{
				AddNodeStateToHashTable(node.FullPath, null);
				if (node.Nodes == null || node.Nodes.Count == 0)
				{
					StoreNodeColor.Add(node.FullPath, node.ForeColor);
				}
				if (node.IsExpanded)
				{
					ExecStoreNodeState(node);
				}
			}
			else if (node.IsExpanded)
			{
				AddNodeStateToHashTable(node.FullPath, node.IsExpanded);
				ExecStoreNodeState(node);
			}
			else if (!node.IsExpanded)
			{
				AddNodeStateToHashTable(node.FullPath, node.IsExpanded);
			}
		}
	}

	public void SetTreeNodeState(TreeNode treeNode, TreeView treeView)
	{
		if (treeNode.Nodes == null || treeNode.Nodes.Count == 0)
		{
			return;
		}
		bool? findFlag = null;
		foreach (TreeNode node in treeNode.Nodes)
		{
			findFlag = FindNodeStateByFullPath(node.FullPath);
			if (!findFlag.HasValue)
			{
				Color color = FindNodeColorByFullPath(node.FullPath);
				if (color != Color.White)
				{
					node.ForeColor = color;
					string tag = node.FullPath;
					if (tag != "")
					{
						string[] strtag = Regex.Split(tag, "\\\\", RegexOptions.IgnoreCase);
						if (strtag.Count() < 3)
						{
							break;
						}
						int guid = Convert.ToInt32(node.Parent.Parent.Tag);
						int mode = ((!(strtag[1] == Lang.Txt("AddFormSpectrums.FullScan"))) ? 1 : 0);
						string result = Regex.Replace(strtag[2], "[^0-9]+", "");
						int runindex = Convert.ToInt32(result) - 1;
						tag = node.Parent.Parent.Tag.ToString() + "," + node.Parent.Tag.ToString() + "," + node.Tag.ToString();
						IEnumerable<SpectrumInfos> currentspectrum = experiment.Spectrums.Where((SpectrumInfos spectrum) => spectrum.sampleId == guid && spectrum.scanType == mode && spectrum.scanIndex == runindex && spectrum.isTest);
						if (currentspectrum != null && currentspectrum.Count() > 0)
						{
							DrawSpectrum(currentspectrum.First(), currentspectrum.First().label, node.ForeColor, tag, bCheck: true);
						}
						node.Parent.Parent.ExpandAll();
					}
				}
				node.Checked = true;
			}
			else if (findFlag == true)
			{
				node.Expand();
			}
			SetTreeNodeState(node, treeView);
		}
	}

	private void toolStripButtonRefresh_Click(object sender, EventArgs e)
	{
		treeSpectrum.AfterCheck -= treeSpectrum_AfterCheck;
		spectraGraph.GraphPane.CurveList.Clear();
		spectraGraph.RemoveAllLabels();
		ClearStoreNodeState();
		foreach (TreeNode treeNode2 in treeSpectrum.Nodes)
		{
			ExecStoreNodeState(treeNode2);
		}
		SetupSpectrumTree();
		foreach (TreeNode treeNode in treeSpectrum.Nodes)
		{
			SetTreeNodeState(treeNode, treeSpectrum);
		}
		treeSpectrum.AfterCheck += treeSpectrum_AfterCheck;
		ApplyResources();
	}

	private void treeSpectrum_AfterCheck(object sender, TreeViewEventArgs e)
	{
		try
		{
			if (e.Node.Nodes.Count > 0)
			{
				bool NoFalse = true;
				foreach (TreeNode tn in e.Node.Nodes)
				{
					if (!tn.Checked)
					{
						NoFalse = false;
					}
				}
				if (e.Node.Checked || NoFalse)
				{
					foreach (TreeNode tn3 in e.Node.Nodes)
					{
						if (tn3.Checked != e.Node.Checked)
						{
							tn3.Checked = e.Node.Checked;
						}
					}
				}
			}
			if (e.Node.Parent != null && e.Node.Parent != null)
			{
				bool ParentNode = true;
				foreach (TreeNode tn2 in e.Node.Parent.Nodes)
				{
					if (!tn2.Checked)
					{
						ParentNode = false;
					}
				}
				if (e.Node.Parent.Checked != ParentNode && (!e.Node.Checked || (e.Node.Checked && !e.Node.Parent.Checked)))
				{
					e.Node.Parent.Checked = ParentNode;
				}
			}
		}
		catch (Exception)
		{
		}
		if (e.Node.Parent == null || (!(e.Node.Parent.Text == Lang.Txt("AddFormSpectrums.FullScan")) && !(e.Node.Parent.Text == Lang.Txt("AddFormSpectrums.PeakScan"))))
		{
			return;
		}
		try
		{
			int rootNode = treeSpectrum.Nodes.IndexOf(e.Node.Parent.Parent);
			int index = e.Node.Index;
			SamplesInfos sample = experiment.Samples[rootNode];
			string tag = e.Node.Parent.Parent.Tag.ToString() + "," + e.Node.Parent.Tag.ToString() + "," + e.Node.Tag.ToString();
			if (e.Node.Parent.Text == Lang.Txt("AddFormSpectrums.FullScan"))
			{
				IEnumerable<SpectrumInfos> spectrums = experiment.Spectrums.Where((SpectrumInfos spectrum) => spectrum.sampleId == sample.guid && spectrum.scanType == 0 && spectrum.scanIndex == index && spectrum.isTest);
				if (spectrums != null && spectrums.Count() > 0)
				{
					DrawSpectrum(spectrums.ElementAt(0), sample.label, e.Node.ForeColor, tag, e.Node.Checked);
				}
			}
			else
			{
				IEnumerable<SpectrumInfos> spectrums2 = experiment.Spectrums.Where((SpectrumInfos spectrum) => spectrum.sampleId == sample.guid && (spectrum.scanType == 1 || spectrum.scanType == 2) && spectrum.scanIndex == index && spectrum.isTest);
				if (spectrums2 != null && spectrums2.Count() > 0)
				{
					DrawSpectrum(spectrums2.ElementAt(0), sample.label, e.Node.ForeColor, tag, e.Node.Checked);
				}
			}
		}
		catch (Exception)
		{
		}
	}

	private void treeSpectrum_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e)
	{
		if (e.Node.Parent == null || e.Node.Parent.Parent == null)
		{
			return;
		}
		ColorDialog colorDialog = new ColorDialog();
		if (colorDialog.ShowDialog() == DialogResult.OK)
		{
			e.Node.ForeColor = colorDialog.Color;
		}
		GraphPane pane = spectraGraph.GraphPane;
		List<int> indexList = new List<int>();
		bool bExisted = false;
		string tag = e.Node.Parent.Parent.Tag.ToString() + "," + e.Node.Parent.Tag.ToString() + "," + e.Node.Tag.ToString();
		for (int i = 0; i < pane.CurveList.Count; i++)
		{
			if (pane.CurveList[i].Tag.ToString() == tag)
			{
				bExisted = true;
				LineItem line = pane.CurveList[i] as LineItem;
				line.Color = e.Node.ForeColor;
				indexList.Add(i);
			}
		}
		spectraGraph.ChangeLabel(tag, e.Node.ForeColor);
		spectraGraph.Refresh();
	}

	protected override void Dispose(bool disposing)
	{
		if (disposing && components != null)
		{
			components.Dispose();
		}
		base.Dispose(disposing);
	}

	private void InitializeComponent()
	{
		this.components = new System.ComponentModel.Container();
		System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ICP_MS.Plugin.Experiment.FormSpectrums));
		this.toolStrip2 = new System.Windows.Forms.ToolStrip();
		this.toolStripLabel1 = new System.Windows.Forms.ToolStripLabel();
		this.txtThreshold = new System.Windows.Forms.ToolStripTextBox();
		this.tsbtnShowLabel = new System.Windows.Forms.ToolStripButton();
		this.toolStripButtonRefresh = new System.Windows.Forms.ToolStripButton();
		this.tsbtnSaveExcel = new System.Windows.Forms.ToolStripButton();
		this.treeSpectrum = new System.Windows.Forms.TreeView();
		this.splitContainer1 = new System.Windows.Forms.SplitContainer();
		this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
		this.spectraGraph = new ICP_MS.Plugin.Experiment.LabelGraph();
		this.toolStrip2.SuspendLayout();
		((System.ComponentModel.ISupportInitialize)this.splitContainer1).BeginInit();
		this.splitContainer1.Panel1.SuspendLayout();
		this.splitContainer1.Panel2.SuspendLayout();
		this.splitContainer1.SuspendLayout();
		this.tableLayoutPanel1.SuspendLayout();
		base.SuspendLayout();
		this.toolStrip2.AutoSize = false;
		this.toolStrip2.BackColor = System.Drawing.SystemColors.Control;
		this.toolStrip2.Dock = System.Windows.Forms.DockStyle.Fill;
		this.toolStrip2.Items.AddRange(new System.Windows.Forms.ToolStripItem[5] { this.toolStripLabel1, this.txtThreshold, this.tsbtnShowLabel, this.toolStripButtonRefresh, this.tsbtnSaveExcel });
		this.toolStrip2.Location = new System.Drawing.Point(0, 0);
		this.toolStrip2.Name = "toolStrip2";
		this.toolStrip2.RenderMode = System.Windows.Forms.ToolStripRenderMode.System;
		this.toolStrip2.Size = new System.Drawing.Size(772, 26);
		this.toolStrip2.TabIndex = 17;
		this.toolStrip2.Text = "toolStrip2";
		this.toolStripLabel1.Name = "toolStripLabel1";
		this.toolStripLabel1.Size = new System.Drawing.Size(56, 23);
		this.toolStripLabel1.Text = "峰阈值：";
		this.txtThreshold.Name = "txtThreshold";
		this.txtThreshold.Size = new System.Drawing.Size(100, 26);
		this.txtThreshold.Text = "1000";
		this.txtThreshold.TextChanged += new System.EventHandler(txtThreshold_TextChanged);
		this.tsbtnShowLabel.Checked = true;
		this.tsbtnShowLabel.CheckState = System.Windows.Forms.CheckState.Checked;
		this.tsbtnShowLabel.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text;
		this.tsbtnShowLabel.Image = (System.Drawing.Image)resources.GetObject("tsbtnShowLabel.Image");
		this.tsbtnShowLabel.ImageTransparentColor = System.Drawing.Color.Magenta;
		this.tsbtnShowLabel.Name = "tsbtnShowLabel";
		this.tsbtnShowLabel.Size = new System.Drawing.Size(60, 23);
		this.tsbtnShowLabel.Text = "标定元素";
		this.tsbtnShowLabel.Click += new System.EventHandler(tsbtnShowLabel_Click);
		this.toolStripButtonRefresh.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text;
		this.toolStripButtonRefresh.Image = (System.Drawing.Image)resources.GetObject("toolStripButtonRefresh.Image");
		this.toolStripButtonRefresh.ImageTransparentColor = System.Drawing.Color.Magenta;
		this.toolStripButtonRefresh.Name = "toolStripButtonRefresh";
		this.toolStripButtonRefresh.Size = new System.Drawing.Size(36, 23);
		this.toolStripButtonRefresh.Text = "刷新";
		this.toolStripButtonRefresh.Click += new System.EventHandler(toolStripButtonRefresh_Click);
		this.tsbtnSaveExcel.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
		this.tsbtnSaveExcel.Image = ICP_MS.Plugin.Experiment.Properties.Resources.Save;
		this.tsbtnSaveExcel.ImageTransparentColor = System.Drawing.Color.Magenta;
		this.tsbtnSaveExcel.Name = "tsbtnSaveExcel";
		this.tsbtnSaveExcel.Size = new System.Drawing.Size(23, 23);
		this.tsbtnSaveExcel.Text = "数据导出";
		this.tsbtnSaveExcel.Click += new System.EventHandler(tsbtnSaveExcel_Click);
		this.treeSpectrum.CheckBoxes = true;
		this.treeSpectrum.Dock = System.Windows.Forms.DockStyle.Fill;
		this.treeSpectrum.Location = new System.Drawing.Point(0, 0);
		this.treeSpectrum.Name = "treeSpectrum";
		this.treeSpectrum.Size = new System.Drawing.Size(130, 516);
		this.treeSpectrum.TabIndex = 15;
		this.treeSpectrum.AfterCheck += new System.Windows.Forms.TreeViewEventHandler(treeSpectrum_AfterCheck);
		this.treeSpectrum.BeforeExpand += new System.Windows.Forms.TreeViewCancelEventHandler(treeSpectrum_BeforeExpand);
		this.treeSpectrum.NodeMouseClick += new System.Windows.Forms.TreeNodeMouseClickEventHandler(treeSpectrum_NodeMouseClick);
		this.treeSpectrum.NodeMouseDoubleClick += new System.Windows.Forms.TreeNodeMouseClickEventHandler(treeSpectrum_NodeMouseDoubleClick);
		this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
		this.splitContainer1.Location = new System.Drawing.Point(0, 0);
		this.splitContainer1.Name = "splitContainer1";
		this.splitContainer1.Panel1.Controls.Add(this.treeSpectrum);
		this.splitContainer1.Panel2.Controls.Add(this.tableLayoutPanel1);
		this.splitContainer1.Size = new System.Drawing.Size(906, 516);
		this.splitContainer1.SplitterDistance = 130;
		this.splitContainer1.TabIndex = 19;
		this.tableLayoutPanel1.ColumnCount = 1;
		this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50f));
		this.tableLayoutPanel1.Controls.Add(this.toolStrip2, 0, 0);
		this.tableLayoutPanel1.Controls.Add(this.spectraGraph, 0, 1);
		this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
		this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0);
		this.tableLayoutPanel1.Name = "tableLayoutPanel1";
		this.tableLayoutPanel1.RowCount = 2;
		this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 5.232558f));
		this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 94.76744f));
		this.tableLayoutPanel1.Size = new System.Drawing.Size(772, 516);
		this.tableLayoutPanel1.TabIndex = 0;
		this.spectraGraph.AutoSize = true;
		this.spectraGraph.Dock = System.Windows.Forms.DockStyle.Fill;
		this.spectraGraph.Location = new System.Drawing.Point(3, 29);
		this.spectraGraph.Name = "spectraGraph";
		this.spectraGraph.ScrollGrace = 0.0;
		this.spectraGraph.ScrollMaxX = 0.0;
		this.spectraGraph.ScrollMaxY = 0.0;
		this.spectraGraph.ScrollMaxY2 = 0.0;
		this.spectraGraph.ScrollMinX = 0.0;
		this.spectraGraph.ScrollMinY = 0.0;
		this.spectraGraph.ScrollMinY2 = 0.0;
		this.spectraGraph.Size = new System.Drawing.Size(766, 484);
		this.spectraGraph.TabIndex = 18;
		base.AutoScaleDimensions = new System.Drawing.SizeF(6f, 12f);
		base.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
		base.ClientSize = new System.Drawing.Size(906, 516);
		base.Controls.Add(this.splitContainer1);
		base.Name = "FormSpectrums";
		base.ShowIcon = false;
		this.Text = "FormSpectrums";
		base.Load += new System.EventHandler(FormSpectrums_Load);
		this.toolStrip2.ResumeLayout(false);
		this.toolStrip2.PerformLayout();
		this.splitContainer1.Panel1.ResumeLayout(false);
		this.splitContainer1.Panel2.ResumeLayout(false);
		((System.ComponentModel.ISupportInitialize)this.splitContainer1).EndInit();
		this.splitContainer1.ResumeLayout(false);
		this.tableLayoutPanel1.ResumeLayout(false);
		this.tableLayoutPanel1.PerformLayout();
		base.ResumeLayout(false);
	}
}
